package com.wanxing.sellerapp.upload;

import android.os.SystemClock;

import org.jetbrains.annotations.NotNull;

import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;


public class ReUploadToOssDelay implements Delayed {


    private long expire; // 过期时间

    // 重传文件名称
    private String filePath;

    public ReUploadToOssDelay(String filePath) {
        // 默认10秒后重传
        this.expire = System.currentTimeMillis() + 10 * 1000;
        this.filePath = filePath;
    }

    public ReUploadToOssDelay(long delayTime, String filePath) {
        this.expire = System.currentTimeMillis() + delayTime;
        this.filePath = filePath;
    }

    @Override
    public long getDelay(@NotNull TimeUnit timeUnit) {
        return timeUnit.convert(this.expire - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
    }

    @Override
    public int compareTo(@NotNull Delayed o) {
        long f = this.getDelay(TimeUnit.MILLISECONDS) - o.getDelay(TimeUnit.MILLISECONDS);
        return (int) f;
    }


    public String getFilePath() {
        return filePath;
    }
}
